//
//  TTProgressView.m
//  TTWeibo
//
//  Created by 陶宏路 on 16/7/21.
//  Copyright © 2016年 陶路路. All rights reserved.
//

#import "TTProgressView.h"

@interface TTProgressView ()

@property (nonatomic,strong)NSTimer* timer;
@property (nonatomic,assign) BOOL anima;

@end
@implementation TTProgressView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.tintColor = [UIColor orangeColor];
        
    }
    
    return self;
}


-(void)valueChange{

    if (self.anima) {
        
        self.progress+=0.05;
        
        if (self.progress>=0.95) {
            
            self.progress = 1;
        }
    }else{
        
        [self.timer invalidate];
        self.progress = 1;
        self.hidden = YES;
        
    }
}

-(void)starAnimation{
    
    self.anima = YES;
    self.progress = 0;
    self.hidden = NO;
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1/60 target:self selector:@selector(valueChange) userInfo:nil repeats:YES];
}

-(void)endAnimation{
    
    self.anima = NO;
    [self.timer invalidate];
}

-(void)remove{
    
    [self removeFromSuperview];
}

-(void)dealloc{
    
    [self.timer invalidate];
}
@end
